/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : main.c
  * @brief          : Main program body
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
  * All rights reserved.</center></h2>
  *
  * This software component is licensed by ST under BSD 3-Clause license,
  * the "License"; You may not use this file except in compliance with the
  * License. You may obtain a copy of the License at:
  *                        opensource.org/licenses/BSD-3-Clause
  *
  ******************************************************************************
  */
/* USER CODE END Header */

/* Includes ------------------------------------------------------------------*/
#include "main.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "ssd2828.h"
//#include "R69434.h"
//#include "ST7796S__PH035NA_01B.h"
#include "ST7703__BV055HDE_N47_3Q00.h"

/* USER CODE END Includes */

/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */

/* USER CODE END PTD */

/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */

/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */

/* USER CODE END PM */

/* Private variables ---------------------------------------------------------*/
UART_HandleTypeDef huart1;

/* USER CODE BEGIN PV */

/* USER CODE END PV */

/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_USART1_UART_Init(void);
static void MX_NVIC_Init(void);
/* USER CODE BEGIN PFP */

/* USER CODE END PFP */

/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */

int _write(int file, char *ptr, int len)
{
  switch (file)
    {
    case STDOUT_FILENO: //stdout
        HAL_UART_Transmit(&huart1, (uint8_t*)ptr, len, 0xff);
        break;
    case STDERR_FILENO: // stderr 
        // Send the string somewhere
        break;
    default:
        return -1;
    }
    return len;
}


void SPI_2825_WrReg(U8 c,U16 value)
{
	CLR_CS();
	W_C(c);
	W_D(value&0xff);
	W_D((value>>8)&0xff);	
	SET_CS();	
}

void SSD_Single(U8 reg, U8 dat)
{
	GP_COMMAD_PA(2);W_D(reg);W_D(dat);
}


void init(void)
{
  W_C(0Xb7);W_D(0X50);W_D(0X00);	
W_C(0XB8);W_D(0X00);W_D(0X00);
W_C(0XB9);W_D(0X00);W_D(0X00);
W_C(0XBA);W_D(0X14);W_D(0X42);
W_C(0XBB);W_D(0X03);W_D(0X00);
W_C(0XB9);W_D(0X01);W_D(0X00);
W_C(0XDE);W_D(0X03);W_D(0X00);
W_C(0XC9);W_D(0X02);W_D(0X23);
  /////////////////////////////////////


  SSD_Single(0xE0,0x00);

SSD_Single(0xE1,0x93);
SSD_Single(0xE2,0x65);
SSD_Single(0xE3,0xF8);



SSD_Single(0xE0,0x00);
SSD_Single(0x70,0x10);	//DC0,DC1
SSD_Single(0x71,0x13);	//DC2,DC3
SSD_Single(0x72,0x06);	//DC7



/*SSD_Single(0xE0,0x00);
//SSD_Single(0x80,0x02);	// lane 3
SSD_Single(0x80,0x01);	// lane 2
*/


/*readMipi(3, 1, 0x72, buffer);
DebugPrintf("0x72: 0x%04x \r\n", buffer[0]);*/

/*SSD_Single(0x4a,0x30);
readMipi(3, 1, 0x4a, buffer);
DebugPrintf("0x4a: 0x%04x \r\n", buffer[0]);*/



SSD_Single(0xE0,0x01);

//SSD_Single(0x4a,0x30); //bist



SSD_Single(0x00,0x00);
SSD_Single(0x01,0xA0);
SSD_Single(0x03,0x00);
SSD_Single(0x04,0xA0);

SSD_Single(0x17,0x00);
SSD_Single(0x18,0xB1);
SSD_Single(0x19,0x01);
SSD_Single(0x1A,0x00);
SSD_Single(0x1B,0xB1);  //VGMN=0
SSD_Single(0x1C,0x01);

SSD_Single(0x1F,0x3E);     //VGH_R  = 15V
SSD_Single(0x20,0x2D);     //VGL_R  = -12V
SSD_Single(0x21,0x2D);     //VGL_R2 = -12V
SSD_Single(0x22,0x0E);     //PA[6]=0, PA[5]=0, PA[4]=0, PA[0]=0
SSD_Single(0x25,0x50);

SSD_Single(0x37,0x19);	//SS=1,BGR=1

SSD_Single(0x38,0x05);	//JDT=101 zigzag inversion
SSD_Single(0x39,0x08);	//RGB_N_EQ1, modify 20140806
SSD_Single(0x3A,0x12);	//RGB_N_EQ2, modify 20140806
SSD_Single(0x3C,0x78);	//SET EQ3 for TE_H
SSD_Single(0x3E,0x80);	//SET CHGEN_OFF, modify 20140806
SSD_Single(0x3F,0x80);	//SET CHGEN_OFF2, modify 20140806


SSD_Single(0x40,0x06);	//RSO=800 RGB
SSD_Single(0x41,0xA0);	//LN=640->1280 line
SSD_Single(0x4B,0x04);

SSD_Single(0x55,0x01);	//DCDCM=0001, JD PWR_IC
SSD_Single(0x56,0x01);
SSD_Single(0x57,0x69);
SSD_Single(0x58,0x0A);
SSD_Single(0x59,0x0A);	//VCL = -2.9V
SSD_Single(0x5A,0x28);	//VGH = 19V
SSD_Single(0x5B,0x19);	//VGL = -11V




SSD_Single(0x5D,0x7F); //18
SSD_Single(0x5E,0x66); //17
SSD_Single(0x5F,0x56); //16
SSD_Single(0x60,0x4A); //15
SSD_Single(0x61,0x46); //14
SSD_Single(0x62,0x36); //13
SSD_Single(0x63,0x3B); //12
SSD_Single(0x64,0x24); //11
SSD_Single(0x65,0x3C); //10
SSD_Single(0x66,0x3A); //9
SSD_Single(0x67,0x39); //8
SSD_Single(0x68,0x55); //7
SSD_Single(0x69,0x42); //6
SSD_Single(0x6A,0x48); //5
SSD_Single(0x6B,0x38); //4
SSD_Single(0x6C,0x33); //3
SSD_Single(0x6D,0x25); //2
SSD_Single(0x6E,0x15); //1
SSD_Single(0x6F,0x0A); //0
SSD_Single(0x70,0x7F); //18
SSD_Single(0x71,0x66); //17
SSD_Single(0x72,0x56); //16
SSD_Single(0x73,0x4A); //15
SSD_Single(0x74,0x46); //14
SSD_Single(0x75,0x36); //13
SSD_Single(0x76,0x3B); //12
SSD_Single(0x77,0x24); //11
SSD_Single(0x78,0x3C); //10
SSD_Single(0x79,0x3A); //9
SSD_Single(0x7A,0x39); //8
SSD_Single(0x7B,0x55); //7
SSD_Single(0x7C,0x42); //6
SSD_Single(0x7D,0x48); //5
SSD_Single(0x7E,0x38); //4
SSD_Single(0x7F,0x33); //3
SSD_Single(0x80,0x25); //2
SSD_Single(0x81,0x15); //1
SSD_Single(0x82,0x0A); //0


SSD_Single(0xE0,0x02);

SSD_Single(0x00,0x47);
SSD_Single(0x01,0x47);
SSD_Single(0x02,0x45);
SSD_Single(0x03,0x45);
SSD_Single(0x04,0x4B);
SSD_Single(0x05,0x4B);
SSD_Single(0x06,0x49);
SSD_Single(0x07,0x49);
SSD_Single(0x08,0x41);
SSD_Single(0x09,0x1F);
SSD_Single(0x0A,0x1F);
SSD_Single(0x0B,0x1F);
SSD_Single(0x0C,0x1F);
SSD_Single(0x0D,0x1F);
SSD_Single(0x0E,0x1F);
SSD_Single(0x0F,0x43);
SSD_Single(0x10,0x1F);
SSD_Single(0x11,0x1F);
SSD_Single(0x12,0x1F);
SSD_Single(0x13,0x1F);
SSD_Single(0x14,0x1F);
SSD_Single(0x15,0x1F);

SSD_Single(0x16,0x46);
SSD_Single(0x17,0x46);
SSD_Single(0x18,0x44);
SSD_Single(0x19,0x44);
SSD_Single(0x1A,0x4A);
SSD_Single(0x1B,0x4A);
SSD_Single(0x1C,0x48);
SSD_Single(0x1D,0x48);
SSD_Single(0x1E,0x40);
SSD_Single(0x1F,0x1F);
SSD_Single(0x20,0x1F);
SSD_Single(0x21,0x1F);
SSD_Single(0x22,0x1F);
SSD_Single(0x23,0x1F);
SSD_Single(0x24,0x1F);
SSD_Single(0x25,0x42);
SSD_Single(0x26,0x1F);
SSD_Single(0x27,0x1F);
SSD_Single(0x28,0x1F);
SSD_Single(0x29,0x1F);
SSD_Single(0x2A,0x1F);
SSD_Single(0x2B,0x1F);

SSD_Single(0x2C,0x11);
SSD_Single(0x2D,0x0F);
SSD_Single(0x2E,0x0D);
SSD_Single(0x2F,0x0B);
SSD_Single(0x30,0x09);
SSD_Single(0x31,0x07);
SSD_Single(0x32,0x05);
SSD_Single(0x33,0x18);
SSD_Single(0x34,0x17);
SSD_Single(0x35,0x1F);
SSD_Single(0x36,0x01);
SSD_Single(0x37,0x1F);
SSD_Single(0x38,0x1F);
SSD_Single(0x39,0x1F);
SSD_Single(0x3A,0x1F);
SSD_Single(0x3B,0x1F);
SSD_Single(0x3C,0x1F);
SSD_Single(0x3D,0x1F);
SSD_Single(0x3E,0x1F);
SSD_Single(0x3F,0x13);
SSD_Single(0x40,0x1F);
SSD_Single(0x41,0x1F);

SSD_Single(0x42,0x10);
SSD_Single(0x43,0x0E);
SSD_Single(0x44,0x0C);
SSD_Single(0x45,0x0A);
SSD_Single(0x46,0x08);
SSD_Single(0x47,0x06);
SSD_Single(0x48,0x04);
SSD_Single(0x49,0x18);
SSD_Single(0x4A,0x17);
SSD_Single(0x4B,0x1F);
SSD_Single(0x4C,0x00);
SSD_Single(0x4D,0x1F);
SSD_Single(0x4E,0x1F);
SSD_Single(0x4F,0x1F);
SSD_Single(0x50,0x1F);
SSD_Single(0x51,0x1F);
SSD_Single(0x52,0x1F);
SSD_Single(0x53,0x1F);
SSD_Single(0x54,0x1F);
SSD_Single(0x55,0x12);
SSD_Single(0x56,0x1F);
SSD_Single(0x57,0x1F);

SSD_Single(0x58,0x40);
SSD_Single(0x59,0x00);
SSD_Single(0x5A,0x00);
SSD_Single(0x5B,0x30);
SSD_Single(0x5C,0x03);
SSD_Single(0x5D,0x30);
SSD_Single(0x5E,0x01);
SSD_Single(0x5F,0x02);
SSD_Single(0x60,0x00);
SSD_Single(0x61,0x01);
SSD_Single(0x62,0x02);
SSD_Single(0x63,0x03);
SSD_Single(0x64,0x6B);
SSD_Single(0x65,0x00);
SSD_Single(0x66,0x00);
SSD_Single(0x67,0x73);
SSD_Single(0x68,0x05);
SSD_Single(0x69,0x06);
SSD_Single(0x6A,0x6B);
SSD_Single(0x6B,0x08);
SSD_Single(0x6C,0x00);
SSD_Single(0x6D,0x0A);
SSD_Single(0x6E,0x0A);
SSD_Single(0x6F,0x88);
SSD_Single(0x70,0x00);
SSD_Single(0x71,0x00);
SSD_Single(0x72,0x06);
SSD_Single(0x73,0x7B);
SSD_Single(0x74,0x00);
SSD_Single(0x75,0x07);
SSD_Single(0x76,0x00);
SSD_Single(0x77,0x5D);
SSD_Single(0x78,0x17);
SSD_Single(0x79,0x1F);
SSD_Single(0x7A,0x00);
SSD_Single(0x7B,0x00);
SSD_Single(0x7C,0x00);
SSD_Single(0x7D,0x03);
SSD_Single(0x7E,0x7B);



SSD_Single(0xE0,0x01);
SSD_Single(0x0E,0x00);	//LEDON output VCSW2

SSD_Single(0xE0,0x03);
SSD_Single(0x98,0x3F);	//From 2E to 2F, LED_VOL

SSD_Single(0xE0,0x04);
SSD_Single(0x09,0x10);
SSD_Single(0x2B,0x2B);
SSD_Single(0x2E,0x44);
SSD_Single(0x09,0x10);



SSD_Single(0xE0,0x00);
SSD_Single(0xE6,0x02);
SSD_Single(0xE7,0x02);











// Display On
GP_COMMAD_PA(1);W_D(0x11);delay_ms(10); 
GP_COMMAD_PA(1);W_D(0x29);delay_ms(10); 
// Display On
GP_COMMAD_PA(2);W_D(0x11);W_D(0x00);delay_ms(10); 
GP_COMMAD_PA(2);W_D(0x29);W_D(0x00);delay_ms(10); 
delay_ms(10); 

SPI_2825_WrReg(0xBC,1);W_C(0xBF);//Display on
W_D(0x11);
delay_ms(200);

SPI_2825_WrReg(0xBC,1);W_C(0xBF);//Display on
W_D(0x29);
delay_ms(10);

SSD_Single(0xE0,0x00);
SSD_Single(0x35,0x00);
SSD_Single(0x3C,0x00);











W_C(0XB7);W_D(0X50);W_D(0X00);
W_C(0XB8);W_D(0X00);W_D(0X00);
W_C(0XB9);W_D(0X00);W_D(0X00);
W_C(0XBA);W_D(0X2C);W_D(0X82);
W_C(0XBB);W_D(0X07);W_D(0X00);
W_C(0XB9);W_D(0X01);W_D(0X00);
W_C(0XC9);W_D(0X02);W_D(0X23);
W_C(0XCA);W_D(0X01);W_D(0X23);
W_C(0XCB);W_D(0X10);W_D(0X05);
W_C(0XCC);W_D(0X05);W_D(0X10);
W_C(0XD0);W_D(0X00);W_D(0X00);
	W_C(0xB1);
	W_D(HSPW);//HSPW 07
	W_D(VSPW);//VSPW 05

	W_C(0xB2);
	W_D(HBPD);//HBPD 0x64=100
	W_D(VBPD);//VBPD 8 减小下移

	W_C(0xB3);
	W_D(HFPD);//HFPD 8
	W_D(VFPD);//VFPD 10

	W_C(0xB4);//Horizontal active period 720=02D0
	W_D(0x20);//013F=319 02D0=720
	W_D(0x03);

	W_C(0xB5);//Vertical active period 1280=0500
	W_D(0x00);//01DF=479 0500=1280
	W_D(0x05);
W_C(0XB6);W_D(0X03);W_D(0X00);
W_C(0XDE);W_D(0X03);W_D(0X00);
//W_C(0XDE);W_D(0X01);W_D(0X00);
W_C(0XD6);W_D(0X05);W_D(0X00);
W_C(0XB7);W_D(0X4B);W_D(0X02);
W_C(0X2C);
}


/* USER CODE END 0 */

/**
  * @brief  The application entry point.
  * @retval int
  */
int main(void)
{
  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */
  

  /* MCU Configuration--------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_USART1_UART_Init();

  /* Initialize interrupts */
  MX_NVIC_Init();
  /* USER CODE BEGIN 2 */

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  printf("Program Start\r\n");

  // test spi
  /*spi_init();
  while(1)
  {
    spi_write(SPI_CMD, 0xa5);
    HAL_Delay(10);
    spi_write(SPI_DAT, 0x5a);
    HAL_Delay(10);
  }*/
  

  spi_init();

  ssd2828_hwreset();

  /*ssd2828_writeReg(0xd4, 0x00, 0xfa);

  uint16_t ssd2828ID = ssd2828_readReg(0xb0);
  
  printf("read 2828 id = 0x%x\r\n", ssd2828ID);*/


  /*for(uint8_t i = 0xB0; i < 0xff; i++)
  {
    uint16_t regData = ssd2828_readReg(i);

    printf("reg(0x%02x) = 0x%04x \r\n", i, regData);
  }*/
  //readMipi()

  //Init_SSD2828(init_ST7703__BV055HDE_N47_3Q00);
  //Init_SSD2828(init_ST7703_BV055HDE_47_IPS_Code);
  init();

  while (1)
  {
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
    /*HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_RESET);
    HAL_Delay(1000);
    HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_SET);
    HAL_Delay(1000);*/

    //uint8_t dat = 0xa5;
    //HAL_UART_Transmit(&huart1, &dat, 1, 100);
    //HAL_Delay(1000);

    //printf("hello stm32\r\n");
    //HAL_Delay(1000);

    /*HAL_GPIO_TogglePin(LCD_RST_GPIO_Port, LCD_RST_Pin);
    HAL_GPIO_TogglePin(LCD_CS_GPIO_Port, LCD_CS_Pin);
    HAL_GPIO_TogglePin(LCD_MOSI_GPIO_Port, LCD_MOSI_Pin);
    HAL_GPIO_TogglePin(LCD_SCK_GPIO_Port, LCD_SCK_Pin);
    HAL_Delay(1000);*/

    /*if(HAL_GPIO_ReadPin(LCD_MISO_GPIO_Port, LCD_MISO_Pin) == GPIO_PIN_SET) 
    {
      HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_SET);
    } else {
      HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_RESET);
    }
    HAL_Delay(200);*/

    printf("Loop...\r\n");
    HAL_Delay(1000);

    
  }
  /* USER CODE END 3 */
}

/**
  * @brief System Clock Configuration
  * @retval None
  */
void SystemClock_Config(void)
{
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

  /** Initializes the CPU, AHB and APB busses clocks 
  */
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
  RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI_DIV2;
  RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL16;
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  {
    Error_Handler();
  }
  /** Initializes the CPU, AHB and APB busses clocks 
  */
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
                              |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
  {
    Error_Handler();
  }
}

/**
  * @brief NVIC Configuration.
  * @retval None
  */
static void MX_NVIC_Init(void)
{
  /* USART1_IRQn interrupt configuration */
  HAL_NVIC_SetPriority(USART1_IRQn, 0, 0);
  HAL_NVIC_EnableIRQ(USART1_IRQn);
}

/**
  * @brief USART1 Initialization Function
  * @param None
  * @retval None
  */
static void MX_USART1_UART_Init(void)
{

  /* USER CODE BEGIN USART1_Init 0 */

  /* USER CODE END USART1_Init 0 */

  /* USER CODE BEGIN USART1_Init 1 */

  /* USER CODE END USART1_Init 1 */
  huart1.Instance = USART1;
  huart1.Init.BaudRate = 115200;
  huart1.Init.WordLength = UART_WORDLENGTH_8B;
  huart1.Init.StopBits = UART_STOPBITS_1;
  huart1.Init.Parity = UART_PARITY_NONE;
  huart1.Init.Mode = UART_MODE_TX_RX;
  huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  huart1.Init.OverSampling = UART_OVERSAMPLING_16;
  if (HAL_UART_Init(&huart1) != HAL_OK)
  {
    Error_Handler();
  }
  /* USER CODE BEGIN USART1_Init 2 */

  /* USER CODE END USART1_Init 2 */

}

/**
  * @brief GPIO Initialization Function
  * @param None
  * @retval None
  */
static void MX_GPIO_Init(void)
{
  GPIO_InitTypeDef GPIO_InitStruct = {0};

  /* GPIO Ports Clock Enable */
  __HAL_RCC_GPIOC_CLK_ENABLE();
  __HAL_RCC_GPIOA_CLK_ENABLE();
  __HAL_RCC_GPIOB_CLK_ENABLE();

  /*Configure GPIO pin Output Level */
  HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_RESET);

  /*Configure GPIO pin Output Level */
  HAL_GPIO_WritePin(GPIOA, LCD_RST_Pin|LCD_CS_Pin|LCD_SCK_Pin|LCD_MOSI_Pin, GPIO_PIN_RESET);

  /*Configure GPIO pin Output Level */
  HAL_GPIO_WritePin(GPIOB, SHUT_Pin|U_CON_Pin, GPIO_PIN_RESET);

  /*Configure GPIO pin : LED_Pin */
  GPIO_InitStruct.Pin = LED_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  HAL_GPIO_Init(LED_GPIO_Port, &GPIO_InitStruct);

  /*Configure GPIO pins : LCD_RST_Pin LCD_CS_Pin LCD_SCK_Pin LCD_MOSI_Pin */
  GPIO_InitStruct.Pin = LCD_RST_Pin|LCD_CS_Pin|LCD_SCK_Pin|LCD_MOSI_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

  /*Configure GPIO pin : LCD_MISO_Pin */
  GPIO_InitStruct.Pin = LCD_MISO_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  HAL_GPIO_Init(LCD_MISO_GPIO_Port, &GPIO_InitStruct);

  /*Configure GPIO pins : SHUT_Pin U_CON_Pin */
  GPIO_InitStruct.Pin = SHUT_Pin|U_CON_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

}

/* USER CODE BEGIN 4 */

/* USER CODE END 4 */

/**
  * @brief  This function is executed in case of error occurrence.
  * @retval None
  */
void Error_Handler(void)
{
  /* USER CODE BEGIN Error_Handler_Debug */
  /* User can add his own implementation to report the HAL error return state */

  /* USER CODE END Error_Handler_Debug */
}

#ifdef  USE_FULL_ASSERT
/**
  * @brief  Reports the name of the source file and the source line number
  *         where the assert_param error has occurred.
  * @param  file: pointer to the source file name
  * @param  line: assert_param error line source number
  * @retval None
  */
void assert_failed(uint8_t *file, uint32_t line)
{ 
  /* USER CODE BEGIN 6 */
  /* User can add his own implementation to report the file name and line number,
     tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  /* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
